define(['./../../initial', './../../model/Project'],
    function () {
        var app = angular.module('App.home');
        app.controller('statisticCtrl', ['$scope', '$timeout', '$rootScope', '$state', '$stateParams', 'allProjects',
            function ($scope, $timeout, $rootScope, $state, $stateParams, allProjects) {

                //工程类型
                $scope.types = [{
                    typeCode: "LongTermSubChord",
                    typeName: "长期收敛"
                }, {
                        typeCode: "CriticalSectionMonitor",
                        typeName: "重点段"
                    }];

                $scope.cityList = allProjects;

                $scope.projectType = $scope.types.filter(function (type) {
                    return type.typeCode === $stateParams.projectTypeCode;
                })[0].typeName;

                //初始化dropdown
                $timeout(function () {
                    $('.dropdown').dropdown();
                }, 300);

                //导航到不同的项目类型中去
                $scope.goProjectType = function (typeCode) {
                    $state.go('statistic', {
                        projectTypeCode: typeCode
                    });
                };

                $scope.goLine = function (lineId) {
                    if ($stateParams.projectTypeCode === 'LongTermSubChord') {
                        $state.go('statistic.lineLong', {
                            lineId: lineId
                        });
                    } else {
                        $state.go('statistic.lineCritical', {
                            lineId: lineId
                        });
                    }
                }
            }
        ]);
    });
